package com.alex;

import com.anythink.core.api.ATAdConst;
import com.bytedance.sdk.openadsdk.CSJSplashAd;
import com.bytedance.sdk.openadsdk.TTFeedAd;
import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd;
import com.bytedance.sdk.openadsdk.TTNativeAd;
import com.bytedance.sdk.openadsdk.TTNativeExpressAd;
import com.bytedance.sdk.openadsdk.TTRewardVideoAd;
import com.bytedance.sdk.openadsdk.mediation.manager.MediationAdEcpmInfo;

import java.util.HashMap;
import java.util.Map;

public class AlexGromoreConst {
    public static final String NATIVE_AD_INTERRUPT_VIDEOPLAY = "mobrain_can_interrupt_video";
    public static final String NATIVE_AD_VIDEOPLAY_BTN_BITMAP = "mobrain_video_play_btn_bitmap";
    public static final String NATIVE_AD_VIDEOPLAY_BTN_SIZE = "mobrain_video_play_btn_SIZE";
    public static final String SPLASH_AD_REUQEST_INFO = "mobrain_splash_request_info";
    static Map<String, Object> getNetworkMap(Object adObject) {
        MediationAdEcpmInfo gmAdEcpmInfo = null;

        try {
            if (adObject instanceof CSJSplashAd) {
                CSJSplashAd csjSplashAd = (CSJSplashAd) adObject;
                gmAdEcpmInfo = csjSplashAd.getMediationManager().getShowEcpm();
            } else if (adObject instanceof TTFullScreenVideoAd) {
                TTFullScreenVideoAd ttInterFullAd = (TTFullScreenVideoAd) adObject;
                gmAdEcpmInfo = ttInterFullAd.getMediationManager().getShowEcpm();
            } else if (adObject instanceof TTRewardVideoAd) {
                TTRewardVideoAd ttRewardVideoAd = (TTRewardVideoAd) adObject;
                gmAdEcpmInfo = ttRewardVideoAd.getMediationManager().getShowEcpm();
            } else if (adObject instanceof TTNativeExpressAd) {
                TTNativeExpressAd ttNativeExpressAd = (TTNativeExpressAd) adObject;
                gmAdEcpmInfo = ttNativeExpressAd.getMediationManager().getShowEcpm();
            } else if (adObject instanceof TTFeedAd) {
                TTFeedAd ttFeedAd = (TTFeedAd) adObject;
                gmAdEcpmInfo = ttFeedAd.getMediationManager().getShowEcpm();
            }

            Map<String, Object> networkMap = new HashMap<>(8);
            if (gmAdEcpmInfo != null) {
                //networkMap.put(ATAdConst.NETWORK_CUSTOM_KEY.NETWORK_ID,//not support in mix version
                //        gmAdEcpmInfo.getAdNetworkPlatformId());
                networkMap.put(ATAdConst.NETWORK_CUSTOM_KEY.NETWORK_NAME,
                        gmAdEcpmInfo.getSdkName());
                networkMap.put(ATAdConst.NETWORK_CUSTOM_KEY.NETWORK_UNIT_ID,
                        gmAdEcpmInfo.getSlotId());
                networkMap.put(ATAdConst.NETWORK_CUSTOM_KEY.NETWORK_ECPM, gmAdEcpmInfo.getEcpm());
                networkMap.put(ATAdConst.NETWORK_CUSTOM_KEY.NETWORK_REQUEST_ID,
                        gmAdEcpmInfo.getRequestId());
                networkMap.put(ATAdConst.NETWORK_CUSTOM_KEY.NETWORK_BIDDING_TYPE,
                        gmAdEcpmInfo.getReqBiddingType());
                if (adObject instanceof TTNativeAd) {
                    TTNativeAd ttNativeAd = (TTNativeAd) adObject;
                    networkMap.put("media_extra_info", ttNativeAd.getMediaExtraInfo());
                }
            }
            return networkMap;
        } catch (Throwable e) {

        }
        return null;
    }
}
